(function(){function t(t){this.editor=t;this.phpParser=this.editor.phpParser;this.listLoaded=false;this.components=this.editor.config.components;this.compNameIndex={};this.componentIncludeMethod="$APPLICATION->IncludeComponent";this.requestUrl="/bitrix/admin/fileman_component_params.php";this.HandleList();this.Init()}t.prototype={Init:function(){BX.addCustomEvent(this.editor,"OnSurrogateDblClick",BX.proxy(this.OnComponentDoubleClick,this))},GetList:function(){return this.components},HandleList:function(){if(this.components&&this.components.items){for(var t=0;t<this.components.items.length;t++)this.compNameIndex[this.components.items[t].name]=t}},IsComponent:function(t){t=this.phpParser.TrimPhpBrackets(t);t=this.phpParser.CleanCode(t);var e=this.phpParser.ParseFunction(t);if(e&&e.name.toUpperCase()==this.componentIncludeMethod.toUpperCase()){var s=this.phpParser.ParseParameters(e.params);return{name:s[0],template:s[1]||"",params:s[2]||{},parentComponent:s[3]&&s[3]!="={false}"?s[3]:false,exParams:s[4]||false}}return false},IsReady:function(){return this.listLoaded},GetSource:function(t,e){if(!this.arVA){this.arVA={}}var s="<?"+this.componentIncludeMethod+"(\n"+'\t"'+t.name+'",\n'+'\t"'+(t.template||"")+'",\n';if(t.params&&!this.editor.util.IsEmptyObject(t.params)){s+="\tArray(\n";var o=t.params,a=Object.keys(o).sort(),i,r,n,p,m,l="SEF_URL_TEMPLATES_".length,h="VARIABLE_ALIASES_".length,d,u,c,f,P=false;for(r=0;r<a.length;r++){i=a[r];if(!o.hasOwnProperty(i))continue;if(!P)P=true;if(typeof o[i]=="string"){o[i]=this.editor.util.stripslashes(o[i])}else if(typeof o[i]=="object"){n="array(";p=0;for(m in o[i]){if(o[i].hasOwnProperty(m)&&typeof o[i][m]=="string"){p++;n+='"'+this.editor.util.stripslashes(o[i][m])+'",'}}if(p>0)n=n.substr(0,n.length-1)+")";else n+=")";o[i]=n}else{continue}if(o["SEF_MODE"]&&o["SEF_MODE"].toUpperCase()=="Y"){if(i.substr(0,l)=="SEF_URL_TEMPLATES_"){f=i.substr(l);this.arVA[f]=this.CatchVariableAliases(o[i]);if(!d){s+='\t\t"'+i.substr(0,l-1)+'" => Array(\n';d=true}s+='\t\t\t"'+i.substr(l)+'" => ';if(this.IsPHPBracket(o[i]))s+=this.TrimPHPBracket(o[i]);else s+='"'+this.editor.util.addslashes(o[i])+'"';s+=",\n";continue}else if(d){c=s.lastIndexOf(",");s=s.substr(0,c)+s.substr(c+1);d=false;s+="\t\t),\n"}if(i.substr(0,h)=="VARIABLE_ALIASES_")continue}else if(o["SEF_MODE"]=="N"){if(i.substr(0,l)=="SEF_URL_TEMPLATES_"||i=="SEF_FOLDER")continue;if(i.substr(0,h)=="VARIABLE_ALIASES_"){if(!u){s+='\t\t"'+i.substr(0,h-1)+'" => Array(\n';u=true}s+='\t\t\t"'+i.substr(h)+'" => "'+this.editor.util.addslashes(o[i])+'",\n';continue}else if(u){c=s.lastIndexOf(",");s=s.substr(0,c)+s.substr(c+1);u=false;s+="\t\t),\n"}}s+='\t\t"'+i+'" => ';if(this.IsPHPBracket(o[i]))s+=this.TrimPHPBracket(o[i]);else if(o[i].substr(0,6).toLowerCase()=="array(")s+=o[i];else s+='"'+this.editor.util.addslashes(o[i])+'"';s+=",\n"}if(u||d){c=s.lastIndexOf(",");s=s.substr(0,c)+s.substr(c+1);s+="\t\t),\n"}if(P){c=s.lastIndexOf(",");s=s.substr(0,c)+s.substr(c+1)}s+="\t)"}else{s+="Array()";if(this.lastDroppedName==t.name&&e){var g=this.editor.GetBxTag(e);if(g&&g.surrogateId){this.ShowPropertiesDialog(g.params,this.editor.GetBxTag(g.surrogateId))}}}if(t.parentComponent!==false||t.exParams!==false){var C=t.parentComponent;if(!C||C.toLowerCase()=="={false}"){s+=",\nfalse"}else{if(this.IsPHPBracket(C))s+=",\n"+this.TrimPHPBracket(C);else s+=",\n'"+C+"'"}if(t.exParams!==false&&typeof t.exParams=="object"){s+=",\nArray(";for(i in t.exParams){if(t.exParams.hasOwnProperty(i)&&typeof t.exParams[i]=="string"){s+="\n\t'"+i+"' => '"+this.editor.util.stripslashes(t.exParams[i])+"',"}}if(s.substr(s.length-1)==",")s=s.substr(0,s.length-1)+"\n";s+=")"}}s+="\n);?>";return s},GetOnDropHtml:function(t){var e={name:t.name};this.lastDroppedName=t.name;return this.GetSource(e)},CatchVariableAliases:function(t){var e=[],s,o,a=t.match(/(\?|&)(.+?)=#([^#]+?)#/gi);if(!a)return e;for(s=0;s<a.length;s++){o=a[s].match(/(\?|&)(.+?)=#([^#]+?)#/i);e[o[3]]=o[2]}return e},LoadParamsList:function(t){oBXComponentParamsManager.LoadComponentParams({name:t.name,parent:false,template:"",exParams:false,currentValues:{}})},GetComponentData:function(t){var e=this.components.items[this.compNameIndex[t]];return e||{}},IsPHPBracket:function(t){return t.substr(0,2)=="={"},TrimPHPBracket:function(t){return t.substr(2,t.length-3)},OnComponentDoubleClick:function(t,e,s,o){if(e&&e.tag=="component"){this.ShowPropertiesDialog(e.params,t)}},ShowPropertiesDialog:function(t,e){var s=BX.clone(t,1);if(!this.oPropertiesDialog){this.oPropertiesDialog=this.editor.GetDialog("componentProperties",{oBXComponentParamsManager:oBXComponentParamsManager});BX.addCustomEvent(this.oPropertiesDialog,"OnDialogSave",BX.proxy(this.SavePropertiesDialog,this));BX.addCustomEvent(this.oPropertiesDialog.oDialog,"onWindowUnRegister",BX.proxy(this.OnDialogClose,this))}this.currentViewedComponentTag=e;this.oPropertiesDialog.SetTitle(BX.message("ComponentPropsTitle").replace("#COMPONENT_NAME#",s.name));this.oPropertiesDialog.SetContent('<span class="bxcompprop-wait-notice">'+BX.message("ComponentPropsWait")+"</span>");this.oPropertiesDialog.Show();if(this.oPropertiesDialog.oDialog.PARTS.CONTENT_DATA){BX.addClass(this.oPropertiesDialog.oDialog.PARTS.CONTENT_DATA,"bxcompprop-outer-wrap")}var o=this;var a=BX.create("DIV");BX.onCustomEvent(oBXComponentParamsManager,"OnComponentParamsDisplay",[{name:s.name,parent:!!s.parentComponent,template:s.template,exParams:s.exParams,currentValues:s.params,container:a,siteTemplate:this.editor.GetTemplateId(),relPath:this.editor.config.relPath,callback:function(t,e){o.PropertiesDialogCallback(t,e)}}])},PropertiesDialogCallback:function(t,e){if(this.oPropertiesDialog.oDialog.PARTS.CONTENT_DATA)BX.addClass(this.oPropertiesDialog.oDialog.PARTS.CONTENT_DATA,"bxcompprop-outer-wrap");this.oPropertiesDialog.SetContent(e);var s=this.oPropertiesDialog.GetContentSize();BX.onCustomEvent(oBXComponentParamsManager,"OnComponentParamsResize",[s.width,s.height])},SavePropertiesDialog:function(){var t=this.currentViewedComponentTag,e=this.editor.GetBxTag(t.params.origId),s=oBXComponentParamsManager.GetParamsValues(),o=oBXComponentParamsManager.GetTemplateValue();t.params.origParams.params=e.params.params=s;t.params.origParams.template=e.params.template=o;this.editor.synchro.FullSyncFromIframe();this.lastDroppedName=""},OnDialogClose:function(){if(this.editor.util.IsEmptyObject(this.currentViewedComponentTag.params.origParams.params)&&this.lastDroppedName){this.SavePropertiesDialog()}},ReloadList:function(){var t=this;this.editor.Request({getData:this.editor.GetReqData("load_components_list",{site_template:this.editor.GetTemplateId(),componentFilter:this.editor.GetComponentFilter(),site:this.editor.GetSiteId()}),handler:function(e){t.components=t.editor.config.components=e;t.HandleList();t.editor.componentsTaskbar.BuildTree(t.components.groups,t.components.items)}})},SetComponentIcludeMethod:function(t){this.componentIncludeMethod=t}};function e(){window.BXHtmlEditor.BXEditorComponents=t;function e(t,s){s=s||{};s.id="bx_component_properties";s.height=600;s.width=800;s.resizable=true;this.oBXComponentParamsManager=s.oBXComponentParamsManager;this.id="components_properties";e.superclass.constructor.apply(this,[t,s]);BX.addClass(this.oDialog.DIV,"bxcompprop-dialog");BX.addCustomEvent(this,"OnDialogSave",BX.proxy(this.Save,this))}BX.extend(e,window.BXHtmlEditor.Dialog);e.prototype.OnResize=function(){var t=this.oDialog.PARTS.CONTENT_DATA.offsetWidth,e=this.oDialog.PARTS.CONTENT_DATA.offsetHeight;BX.onCustomEvent(this.oBXComponentParamsManager,"OnComponentParamsResize",[t,e])};e.prototype.OnResizeFinished=function(){};window.BXHtmlEditor.dialogs.componentProperties=e}if(window.BXHtmlEditor&&window.BXHtmlEditor.dialogs)e();else BX.addCustomEvent(window,"OnEditorBaseControlsDefined",e)})();